<?php
/**
 * Comments module for XOOPS
 *
 * You may not change or alter any portion of this comment or credits
 * of supporting developers from this source code or any supporting source code 
 * which is considered copyrighted (c) material of the original comment or credit authors.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @copyright       The Groups Project http://code.google.com/p/commentsforxoops/
 * @license         http://www.fsf.org/copyleft/gpl.html GNU public license
 * @package         comments
 * @since           2.3.0
 * @author          Hui Xiao < xh.8326@gmail.com >
 * @version         $Id: get.comments.form.php Sat Jul 18 20:19:28 CST 2009
 */

if ( false === defined("XOOPS_ROOT_PATH") || !is_object($xoopsModule) ) { exit(); }

return getCommentForm();

function getCommentForm() {
    global $xoopsModule, $xoopsModuleConfig;
   
    if ( empty($xoopsModule) || !$xoopsModule->getVar("hascomments") || $xoopsModule->getVar("dirname") == "system" ) return false;
    $dirname = $xoopsModule->getVar("dirname");
    include ( XOOPS_ROOT_PATH."/modules/{$dirname}/xoops_version.php" );
    $itemname = $modversion["comments"]["itemName"];
    $url = XOOPS_URL."/modules/comments/ajax.comments.php";
    $loading = "<img src=\"".XOOPS_URL."/modules/comments/images/loading.gif\" alt=\"\" />";
    if ( empty($_GET[$itemname]) ) return false;
    $id = $_GET[$itemname];
    $ret = "<div id=\"getCommentList\">";
    $ret .= "<div style=\"text-align:center; padding: 5px 0;\">{$loading}</div>";
    $ret .= "
<script type=\"text/javascript\">
    var module = \"{$dirname}\";
    var id = \"{$id}\";
    var url = \"{$url}\";
	$(document).ready(function(){ 
		getCommentList(module,id);
	});
	function getCommentList(module, id) {
        $.ajax({
        	type: \"GET\",
        	url: url,
        	data:   \"module=\" + module + \"&id=\" + id,
        	success: function(msg){ 
        		$(\"div[id=getCommentList]\").html(msg);
        	} 
        });
	}
</script>";
    $ret .= "</div>";
    return $ret;
}